package com.bindapp.fragment;

import android.view.LayoutInflater;

import com.bindapp.listener.LoadStatusListener;
import com.bindapp.model.Tab4Model;
import com.gyf.barlibrary.ImmersionBar;

/**
 * Created by tom055 on 2018/6/3.
 */

//tab2

public class MainTab4Fragment extends BaseFragment {
    private Tab4Model model;
    protected ImmersionBar mImmersionBar;

    @Override
    protected void initContent(LayoutInflater inflater) {
        super.initContent(inflater);
        //model=new Tab1Model(getActivity(),new LoadStatusImpl());
        model = new Tab4Model(getActivity(),new LoadStatusImpl());
    }


    @Override
    public void loaddata() {
        super.loaddata();
        AddBaseContentView(loadLayoutModel.getBinding().getRoot());
        model.postRequest();
        //AddBaseContentView(model.getBinding().getRoot());

    }


    class LoadStatusImpl implements LoadStatusListener {

        @Override
        public void show() {
            AddBaseContentView(model.getBinding().getRoot());
        }

        @Override
        public void hide(boolean flag, String msg) {
            loadLayoutModel.setLoadStatus(flag, msg, 0);
            AddBaseContentView(loadLayoutModel.getBinding().getRoot());
        }
    }

    @Override
    public void onVisible() {
        if(isPrepared && isVisible){
            initImmersionBar();
        }
        super.onVisible();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mImmersionBar != null){
            mImmersionBar.destroy();
        }

    }

    protected void initImmersionBar() {
        mImmersionBar = ImmersionBar.with(this);
        mImmersionBar.keyboardEnable(true).statusBarDarkFont(false).init();
    }
}
